package
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;

	public class Buttons extends MovieClip
	{
		private var BG:MovieClip;
		private var iconRollOver:String;

		public function Buttons(buttonType)
		{
			this.gotoAndStop(buttonType);

			BG = this.buttonBG;

			BG.stop();

			this.button.buttonMode = true;
			this.button.mouseChildren = false;
			this.button.useHandCursor = true

			this.addEventListener(MouseEvent.MOUSE_OVER, over, false, 0, true);
			this.addEventListener(MouseEvent.MOUSE_OUT, out, false, 0, true);

			switch(buttonType)
			{
				case 'submit':
				case 'delete':
					iconRollOver = true;
				break;

				case 'startStop':
					this.button.alpha = 1;
					this.button.width = 35;
			}
		}

		private function over(e:MouseEvent)
		{
			BG.gotoAndStop(2);
			if(iconRollOver)
			{
				this.nextFrame();
			}
		}

		private function out(e:MouseEvent)
		{
			BG.gotoAndStop(1);
			if(iconRollOver)
			{
				this.prevFrame();
			}
		}

		public function action(action)
		{
			switch(action)
			{
				case 'play':
					this.nextFrame();
				break;
				case 'pause':
					this.prevFrame();
				break;

				case 'intervals_active':
					this.gotoAndStop('load');
				break;
				case 'intervals_complete':
					this.gotoAndStop('btn');
					BG.stop();
				break;
			}
		}
	}
}